package io;

import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * 输出所有注册用户
 * 思路:
 * 获取当前目录下所有后缀名为.obj的文件，然后每个文件都用对象流反序列化
 * 并输出即可。
 * @author Xiloer
 *
 */
public class Test02 {
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		//获取当前目录下所有obj文件
		FileFilter filter = (file)->file.getName().endsWith(".obj");
		File file = new File(".");
		File[] subs = file.listFiles(filter);
		for(int i=0;i<subs.length;i++) {
			File sub = subs[i];
			FileInputStream fis = new FileInputStream(sub);
			ObjectInputStream ois = new ObjectInputStream(fis);
			Object o = ois.readObject();
			if(o instanceof User) {
				System.out.println(o);
			}			
			ois.close();
		}
	}
}









